package com.crcode.crm.service.role.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.crcode.crm.bean.role.RoleModuleBean;
import com.crcode.crm.dao.role.RoleModuleDao;
import com.crcode.crm.service.role.RoleModuleService;
/**
 * 角色模块关联管理
 * 
 * @author lxw
 * @date 2018年9月12日 下午2:44:52
 * @version V1.0
 */
@Service(value="roleModuleService")
@Transactional
public class RoleModuleServiceImpl implements RoleModuleService {

	@Autowired
	private RoleModuleDao roleModuleDao;

	@Override
	public RoleModuleBean getById(Integer serializable) {

		return this.roleModuleDao.findById(serializable).get();
	}

	@Override
	public RoleModuleBean saveResultBean(RoleModuleBean t) {
		
		return this.roleModuleDao.save(t);
	}

	@Override
	public boolean saveResultBoolean(RoleModuleBean t) {
		try {
			this.roleModuleDao.save(t);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	@Override
	public RoleModuleBean updateResultBean(RoleModuleBean t) {

		return this.roleModuleDao.save(t);
	}

	@Override
	public boolean updateResultBoolean(RoleModuleBean t) {
		try {
			this.roleModuleDao.save(t);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	@Override
	public boolean delete(Integer serializable) {
		try {
			this.roleModuleDao.deleteById(serializable);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	@Override
	public List<RoleModuleBean> getAll() {
		
		return this.roleModuleDao.findAll();
	}

	@Override
	public boolean batchSaveResultBoolean(List<RoleModuleBean> rm) {
		try {
			this.roleModuleDao.saveAll(rm);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	@Override
	public boolean deleteByRoleUuidIn(List<String> roleUuids) {
		try {
			this.roleModuleDao.deleteByRoleUuidIn(roleUuids);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	@Override
	public boolean deleteByModuleUuidIn(List<String> moduleUuids) {
		try {
			this.roleModuleDao.deleteByModuleUuidIn(moduleUuids);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}
	

}
